/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

package com.huawei.api.bean;

/**
 * 报告类型枚举
 *
 * @since 2023/10/28
 */
public enum ReportType {
    JSON("json", new String[]{"json"}),

    XML("xml", new String[] {"xml"}),

    TEXT("txt", new String[] {"txt"});

    private final String[] extensions;

    private final String name;

    ReportType(String name, String[] extension) {
        this.name = name;
        this.extensions = extension;
    }

    /**
     * 是否有某一个后缀名
     *
     * @param otherExtension 后缀名
     * @return true: 是; false: 否
     */
    public boolean hasExtension(String otherExtension) {
        for (String extension : this.extensions) {
            if (extension.equals(otherExtension)) {
                return true;
            }
        }
        return false;
    }
}
